<template>
	<view id="page">
		<nav-bar :navH="navH" :isTabar="false" :isHome="false" :pageName="title"></nav-bar>
		<view class="help" v-if="hasRes">
			<block v-for="(it, k) in lists" :key="k">
				<view class="help-i" @click="goDetail(it.id)">
					<text class="icon">●</text><text>{{it.question}}</text>
					<view class="t">{{it.created_time}}</view>
				</view>
			</block>
		</view>
		<view class="nocont" v-else>暂无内容</view>
		<view class="nomore" v-if="isLoad"><image src='../../static/nomore_img.png' mode="widthFix"></image><text>没有更多了~</text></view>
	</view>
</template>

<script>
	import app from '../../common/index.js'
	export default {
		data() {
			return {
				title: '在线帮助',
				navH: null,
				hasRes: true,
				lists: [],
			}
		},
		onLoad(options) {
			this.navH = this.$store.state.navHeight;
			this.getHelp();
		},
		// 下拉刷新
		onPullDownRefresh() {
			// 获取本地用户信息
			this.getHelp();
			uni.stopPullDownRefresh();
		},
		// 分享转发
		onShareAppMessage() {
			return {
				title: '爱美指南针',
				path: 'pages/index/index',
			}
		},
		methods: {
			/**
			 * @des 获取帮助列表
			 */
			getHelp() {
				app.request({
					url: 'entry/wxapp/GetHelp'
				}, (ret) => {
					let d = ret.data;
					if (d.length > 0) {
						this.lists = d;
					} else {
						this.hasRes = false;
					}
				})
			},
			/**
			 * @des 打开详情
			 */
			goDetail(id) {
				uni.navigateTo({
					url: '../helpdetail/index?id=' + id
				})
			} 
		}
	}
</script>

<style>
	.help {padding: 0 20upx; border-bottom: 1px solid #eee; background-color: #fff;}
	.help .help-i {padding: 20upx 10upx; border-bottom: 1px solid #eee; text-align: left;}
	.help .help-i .icon {display: inline-block; padding-right: 10upx; font-size: 22upx; color: #aaa;}
	.help .help-i .t {display: block; width: 100%; margin: 5upx 0 0 25upx; font-size: 24upx; color: #888;}
</style>